<#if controllerPackage!="">
package ${controllerPackage};
</#if>

<#if entityPackage!="">
import ${entityPackage}.${className};
</#if>
<#if servicePackage!="">
import ${servicePackage}.${className}Service;
</#if>
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
* Created by ${author} on ${date}.
*/
@Controller
@RequestMapping("/${classFieldName}")
public class ${className}Controller {

  @Resource
  ${className}Service ${classFieldName}Service;

  @RequestMapping
  @ResponseBody
  public void defaultRequest(HttpServletResponse response, HttpServletRequest request) throws IOException {
     List<${className}> o = ${classFieldName}Service.findAll();
     PrintWriter out = response.getWriter();
     out.write("<p>Request uri: " + request.getRequestURI() + ".</p>");
     out.write("<p>Controller: " + this.getClass().getName() + ".</p>");
     out.write("<p>Query Result: " + o.size() + " items.</p>");
  }

}
